// pages/alipay-id/alipay-id.js
import user from '../../utils/user'
import { bindAlipayAccount } from '../../api/salary-card'
import { toast, wait } from '../../utils/util'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        isEyeOpen: false,
        alipayAccount: ''
    },
    onLoad(options) {
        this.setData({
            alipayAccount: options.alipayAccount || ''
        })
    },
    onToggleEye() {
        this.setData({
            isEyeOpen: !this.data.isEyeOpen
        })
    },
    onInput(ev) {
        this.setData({
            alipayAccount: ev.detail.value
        })
    },
    async onChangeAccount() {
        await bindAlipayAccount({
            alipayAccount: this.data.alipayAccount
        })
        await user.reLogin()
        wait(100)
        toast('修改成功')
        wx.navigateBack()
    }
})